package com.fzz.learning_forum.dao;

import com.fzz.learning_forum.domain.Course;
import com.fzz.learning_forum.domain.Course_People;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;


@Mapper
@Component
public interface CourseMapping {

    //创建课程
    @Insert("insert into tb_course(teacher_name,teacher_id,course_name,student_num,course_describe,created) values(#{teacher_name},#{teacher_id},#{course_name},#{student_num},#{course_describe},#{created})")
    public Integer createCourse(Course course);

    //分页查询所有课程
    @Select("select * from tb_course")
    public List<Course> selectAllCourse();

    //根据id查询自己创建的所有课程
    @Select("select * from tb_course where teacher_id=#{id}")
    public List<Course> selectCourseById(@Param("id")Integer id);

    //根据id查询课程的详细信息
    @Select("select * from tb_course where id=#{id}")
    public Course selectCourseDetails(@Param("id")Integer id);

    //查询该课程中的所有成员
    @Select("select * from tb_joincourse where course_id=#{id}")
    public List<Course_People> selectCoursePeopleById(@Param("id")Integer id);
}
